package com.ruoyi.testDeal.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.testDeal.domain.basic.ReportBasicinfo;
import com.ruoyi.testDeal.service.IReportBasicinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 报告基本参数信息Controller
 * 
 * @author ruoyi
 * @date 2024-03-29
 */
@RestController
@RequestMapping("/testDeal/reportbasicinfo")
public class ReportBasicinfoController extends BaseController
{
    @Autowired
    private IReportBasicinfoService reportBasicinfoService;

    /**
     * 查询报告基本参数信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ReportBasicinfo reportBasicinfo)
    {
        startPage();
        List<ReportBasicinfo> list = reportBasicinfoService.selectReportBasicinfoList(reportBasicinfo);
        return getDataTable(list);
    }

    /**
     * 导出报告基本参数信息列表
     */
    @Log(title = "报告基本参数信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReportBasicinfo reportBasicinfo)
    {
        List<ReportBasicinfo> list = reportBasicinfoService.selectReportBasicinfoList(reportBasicinfo);
        ExcelUtil<ReportBasicinfo> util = new ExcelUtil<ReportBasicinfo>(ReportBasicinfo.class);
        util.exportExcel(response, list, "报告基本参数信息数据");
    }

    /**
     * 获取报告基本参数信息详细信息
     */
    @GetMapping(value = "/{reportBasicId}")
    public AjaxResult getInfo(@PathVariable("reportBasicId") Long reportBasicId)
    {
        return success(reportBasicinfoService.selectReportBasicinfoByReportBasicId(reportBasicId));
    }

    /**
     * 新增报告基本参数信息
     */
    @Log(title = "报告基本参数信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReportBasicinfo reportBasicinfo)
    {
        return toAjax(reportBasicinfoService.insertReportBasicinfo(reportBasicinfo));
    }

    /**
     * 修改报告基本参数信息
     */
    @Log(title = "报告基本参数信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReportBasicinfo reportBasicinfo)
    {
        return toAjax(reportBasicinfoService.updateReportBasicinfo(reportBasicinfo));
    }

    /**
     * 删除报告基本参数信息
     */
    @Log(title = "报告基本参数信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reportBasicIds}")
    public AjaxResult remove(@PathVariable Long[] reportBasicIds)
    {
        return toAjax(reportBasicinfoService.deleteReportBasicinfoByReportBasicIds(reportBasicIds));
    }
}
